package com.fangyi.yunmusic.controller;

import com.fangyi.yunmusic.mapper.ArtistMapper;
import com.fangyi.yunmusic.mapper.ArtistReviewMapper;
import com.fangyi.yunmusic.pojo.front.end.FEArtistReview;
import com.fangyi.yunmusic.pojo.vo.UserVO;
import com.fangyi.yunmusic.service.ArtistReviewService;
import com.fangyi.yunmusic.service.ArtistService;
import com.fangyi.yunmusic.websocket.CommentNotificationHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/artistReview")
public class ArtistReviewController {
    @Autowired
    private ArtistReviewService artistReviewService;
    @Autowired
    private ArtistService artistService;

    @Autowired
    private CommentNotificationHandler notificationHandler;

    @PostMapping("/add")
    public Object addArtistReview(FEArtistReview feArtistReview){
        artistReviewService.addArtistReview(feArtistReview);
        return "审核添加成功！";
    }
    @PostMapping("/pagination")
    public Object getArtistReview(Integer page, Integer pageSize){
        return artistReviewService.selectArtistReview(page,pageSize);
    }
    @PostMapping("/allow")
    public Object allowToBeArtist(String id){
        UserVO userVO = artistReviewService.allowToBeArtist(id);
        notificationHandler.sendArtistReviewResult(userVO.getId());
        return "审核通过！";
    }
    @PostMapping("/disallow")
    public Object disallowToBeArtist(String id){
        String userId = artistReviewService.deleteArtistReview(id);
        notificationHandler.sendArtistReviewResult(userId);
        return "成功驳回审核！";
    }

}
